import {request, post } from "@/utils/request";
import ApiResult from "@/api/base/ApiResult";
import {
  IAddGiftPackData, IGiftPackGoodsEntity, IMemberConfigEditData, IMemberConfigRes,
  IPayConfigData, IPayConfigItem,
  IRankBenefitItem,
  IRankBenefitsData,
  IRankItem,
  IRankTaskEditData,
  IRankUser, IRuleRes,
  IStoreGoodsDetailData, IUpdateGiftPackData,
  IVipRankAddData, IVipRankRuleData
} from "@/api/modules/vipCenter";
import {IStoreGoodsDetail} from "@/api/modules/pointsMall";

/**
 * 获取vip等级
 */
export function getVipRank():Promise<ApiResult<IRankItem[]>> {
  return request('merchant/memInfo/queryMemInfo', {})
}

/**
 * 新增会员等级
 */
export function addVipRank(data: IVipRankAddData):Promise<ApiResult<any>> {
  return request('merchant/memInfo/insertMemInfo', data)
}

/**
 * 编辑会员等级
 */
export function editVipRank(data: IVipRankAddData):Promise<ApiResult<any>> {
  return request('merchant/memInfo/updateMemInfo', data)
}

/**
 * 删除会员等级
 */
export function deleteVipRank(data: {id: number, name: string}):Promise<ApiResult<any>> {
  return request('merchant/memInfo/removeMemId', data)
}


/**
 * 新增修改任务
 */
export function changeTask(data:IRankTaskEditData):Promise<ApiResult<any>> {
  return request('/merchant/memTask/changeTask', data)
}

/**
 * 更改会员任务状态
 */
export function changeTaskStatus(data: {id: number, name: string}):Promise<ApiResult<any>> {
  return request('/merchant/memTask/changeStatus', data)
}

/**
 * 获取当前等级的会员权益
 */
export function getRankBenefits(data: IRankBenefitsData): Promise<ApiResult<IRankBenefitItem[]>> {
  return request('merchant/member/equity/pageEquity', data)
}

/**
 * 新增会员权益
 * @param data
 */
export function addRankBenefits(data: any): Promise<ApiResult<any>> {
  return request('merchant/member/equity/addEquity/v14', data)
}

export function deleteRankBenefits(data: {id: number, name: string}): Promise<ApiResult<any>> {
  return request('merchant/member/equity/deleteEquity', data)
}

/**
 * 新增商品后，配置商品时，获取单个商家商品
 */
export function getStoreGoodsDetail(data: IStoreGoodsDetailData):Promise<ApiResult<IStoreGoodsDetail>> {
  return request('merchant/member/goods/getStoreGoodsDetail', data)
}

/**
 * 新增会员权益商品
 */
export function addMemberGoods(data: IStoreGoodsDetail): Promise<ApiResult<any>> {
  return request('merchant/member/goods/addGoods', data)
}

/**
 * 获取当前会员等级下的用户
 * @param data
 */
export function getRankUsers(data: {gradleId: number, showCount: number, currentPage: number}):Promise<ApiResult<IRankUser[]>> {
  return request('user/userEntity/pageList', data)
}

/**
 * 获取会员等级规则
 */
export function getVipRankDetail():Promise<ApiResult<IRuleRes>> {
  return request('merchant/memInfo/queryRule', {})
}

/**
 * 获取当前商户会员配置
 */
export function getMemberConfig():Promise<ApiResult<IMemberConfigRes>> {
  return request('merchant/memberConfig', {})
}

/**
 * 提交会员等级规则
 * @param data
 */
export function submitRankDetail(data: IVipRankRuleData):Promise<ApiResult<any>> {
  return request('merchant/memInfo/rule', data)
}

/**
 * 会员配置编辑
 */
export function memberConfigEdit(data: IMemberConfigEditData):Promise<ApiResult<any>> {
  return request('merchant/memberConfigEdit', data)
}

/**
 * 会员支付配置
 * @param data
 */
export function getVipPayConfig(data: IPayConfigData):Promise<ApiResult<IPayConfigItem[]>> {
  return request('', data)
}

/**
 * 删除会员权益商品
 */
export function deleteGoods(data: {id: number}):Promise<ApiResult<any>> {
  return request('merchant/member/goods/delGoods', data)
}

/**
 * 新增礼品包
 */
export function addGiftPack(data: IAddGiftPackData): Promise<ApiResult<any>> {
  return request('merchant/member/goods/addGiftPack', data)
}

/**
 * 更新礼品包
 */
export function updateGiftPack(data: IUpdateGiftPackData): Promise<ApiResult<any>> {
  return request('merchant/member/goods/updateGiftPack', data)
}

/**
 * 删除礼品包
 */
export function deleteGiftPack(data: {id: number}): Promise<ApiResult<any>> {
  return request('merchant/member/goods/delGiftPack', data)
}

/**
 * 新增礼品包规格
 */
export function addGiftProduct(data: IGiftPackGoodsEntity): Promise<ApiResult<any>> {
  return request('merchant/member/goods/addGiftProduct', data)
}
/**
 * 查询分类
 */
 export function getMerchantCategoryApi(data: any): Promise<ApiResult<any>> {
  return request('merchant/member/goods/getMerchantCategory', data)
}
/**
 * 查询商家
 */
 export function getSupplierApi(data: any): Promise<ApiResult<any>> {
  return request('merchant/member/goods/getStore', data)
}

/**
 * 通知配置系统通知下拉框
 */
export function queryMemberMerchantInfos(data: any): Promise<ApiResult<any>> {
  return request('/merchant/queryMerchantInfos', data)
}
